package edu.sctu.nieyu.day20150618.testtwo;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by user01 on 2015/6/18.
 */

/**
 * URL的各种方法的练习
 */
public class URlTest {

    public void getURL(){

        try {
            URL sc = new URL("http://www.sctu.edu.cn");
            URL url = new URL(sc,"/index.html?username=nieyu#testt");
            System.out.println("协议："+url.getProtocol());
            System.out.println("文件路径："+url.getPath());
            System.out.println("文件名："+url.getFile());
            System.out.println("相对路径："+url.getRef());
            System.out.println("查询字符串："+url.getQuery());
            System.out.println("主机名："+url.getHost());
            System.out.println("授权部分："+url.getAuthority());
            System.out.println("端口号："+url.getPort());
            System.out.println("默认端口号："+url.getDefaultPort());
            System.out.println(url.toString());
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        URlTest ut = new URlTest();
        ut.getURL();
    }
}
